home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 574 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: clamage@Eng.Sun.COM (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Is dynamic_cast safe?
  5. Date: 27 Feb 1996 17:52:27 PST
  6. Organization: Sun Microsystems Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4gvb5a$c3s@engnews1.Eng.Sun.COM>
  9. References: <AD58B8389668E1A9@sleipner.nts.mh.se>
  10. Reply-To: clamage@Eng.Sun.COM
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. X-Original-Date: 27 Feb 1996 16:23:06 GMT
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMTO1gUy4NqrwXLNJAQGEZwIAnr9OwLMhm/D25Rz2n6LwECkI+D4gyBgd
  15.     q3kr8VseMnoJHyduqFmJCz4Y4e1V+571m+w9tCDscRWZDcD5pG8sLQ==
  16.     =UBXN
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article AD58B8389668E1A9@sleipner.nts.mh.se, lars.farm@nts.mh.se (Lars Farm) writes:
  20. >     5.2.6  Dynamic cast                           [expr.dynamic.cast]
  21. >   ...
  22. >   6 Otherwise,  v shall be a pointer to or an lvalue of a polymorphic type
  23. >   ...
  24. >What should happen when 'v' is not a pointer to or an lvalue of a
  25. >polymorphic type? return 0? crash? throw bad_cast? undefined?
  26. >   ...
  27. >   8 The  run-time  check  logically  executes  like  this: 
  28. >     [...]  Otherwise, the run-time  check fails.
  29.  
  30. >If fail means undefined, why not require that it returns 0?
  31.  
  32. The dynamic_cast has two failure modes, depending on whether the cast is
  33. of pointer or reference type (the only two kinds allowed). The last
  34. paragraph of the section says a failed pointer cast returns the null
  35. pointer, and a failed reference cast throws the bad_cast exception.
  36. The behavior is completely defined
  37. ---
  38. Steve Clamage, stephen.clamage@eng.sun.com
  39. ---
  40. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  41.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  42.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  43.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  44.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  45. ]
  46.